 $(function(){
	 /* 回填内容 */
	
  })

    //实例化编辑器
    //建议使用工厂方法getEditor创建和引用编辑器实例，如果在某个闭包下引用该编辑器，直接调用UE.getEditor('editor')就能拿到相关的实例
    var ue = UE.getEditor('editor');

     function getContent() {
         setTagAndValue("form1","ctContent",UE.getEditor('editor').getContent());
         contracTemplateAdd();
     }
     function clearLocalData () {
         UE.getEditor('editor').execCommand( "clearlocaldata" );
     }
     function deleteEditor() {
         //disableBtn();
         UE.getEditor('editor').destroy();
     }
     function createEditor() {
         //enableBtn();
         UE.getEditor('editor');
     }
     function disableBtn(str) {
         var div = document.getElementById('btns');
         var btns = UE.dom.domUtils.getElementsByTagName(div, "button");
         for (var i = 0, btn; btn = btns[i++];) {
             if (btn.id == str) {
                 UE.dom.domUtils.removeAttributes(btn, ["disabled"]);
             } else {
                 btn.setAttribute("disabled", "true");
             }
         }
     }
function contracTemplateAdd(){
	if (!Validator.Validate(document.getElementById("form1"), 1)) {
		return;
	}
	$.ajax({ 
	 	url: ctp + "/contracTemplateController/contracTemplateSave.shtml",
	    data: $('#form1').serialize(),
		type : 'POST',
		async:false, 
		success : function(result) {  
			if(result=='1') {  
				jalert9("保存成功！");
				setTimeout(function(){
					parent.searchData();
					closeAttendance();
				},WARN_TIME_OUT);
			}else if(result=='2') {     
				jalert("保存失败，有相同的合同模板名称！");   
			}else if(result=='0') {     
				jalert("保存失败，请联系管理员！");   
			} 
  		}
	});
	
}

function contracTemplatepdf(){
	setTagAndValue("form1","ctContent",UE.getEditor('editor').getContent());
	$.ajax({ 
	 	url: ctp + "/contracTemplateController/contracTemplatepdf.shtml",
	    data: $('#form1').serialize(),
		type : 'POST',
		async:false, 
		success : function(result) {  
			if(result=='1') {  
				jalert9("生成pdf成功！");	
			}
  		}
	});
	
}

//当前弹窗索引
var attendance_index = parent.layui.layer.getFrameIndex(window.name);

//关闭当前弹窗
function closeAttendance(){
	parent.layui.layer.close(attendance_index);
}